package Java.BlackHorse.a01CollectionsTest;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Test3 {
    public static void main(String[] args) {
    ArrayList<String> list1 = new ArrayList<>();
    Collections.addAll(list1,"林黛玉","薛宝钗","贾惜春","贾迎春","贾探春","李纨","史湘云","王熙凤");
    ArrayList<String> list2 = new ArrayList<>();//临时集合

        //点名10次
        for (int i = 1; i <= 10 ; i++) {
            System.out.println("======第"+i+"次点名=====");
            Random r = new Random();
            int count = list1.size();

            for (int j = 0; j < count; j++) {
                int index=r.nextInt(list1.size());
                String name=list1.remove(index);
                list2.add(name);
                System.out.println(name);
            }

            list1.addAll(list2);
            list2.clear();
        }

    }
}
